﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        static void Main(string[] args)
        {
            string html = @"<html><head><title>News</title></head> 
                            <body><p><a href=""http://academy.telerik.com"">Telerik 
                             Academy</a>aims to provide free real-world practical 
                             training for young people who want to turn into 
                             skillful .NET software engineers.</p></body></html>";
         
            int openTagsCount = 0;
            bool hasPrinted=false;
            for (int i = 0; i < html.Length; i++)
            {
                if (html[i] == '<')
                {
                    openTagsCount++;
                    if (hasPrinted == true)
                    {
                        Console.Write(' ');
                        hasPrinted = false;
                    }
                    continue;
                }
                if (html[i] == '>')
                {
                    openTagsCount--;
                    continue;
                }
                if (openTagsCount == 0)
                {
                    Console.Write(html[i]);
                    hasPrinted = true;
                }
            }
            Console.WriteLine();

        }
    }

